<script>
	const index = require('@/api/index/index.js')
	export default {
		data() {
			return {
				// projectId:''
			}
		},
		onLoad(options) {
		},
		async onLaunch() {
			// this.cloud()
			uni.removeStorageSync('tarbar_index')
			console.log('App Launch')
			await this.initData();
		},
		onShow: function() {
			console.log('App Show')
			// getApp().globalData.projectId,globalData.projectId
		},
		onHide: function() {
			console.log('App Hide')
			if (uni.getStorageSync("fenx")) {
				this.getPointsByZhuanFa()
			} 
		},
		methods: {
			cloud(){
				wx.cloud.callFunction({
				  name: 'generateQrCode',
				  data: {
				    scene: '15651039802', // 传递推荐人ID作为参数
				    page: 'pages/index/index', // 小程序码跳转的页面路径
				    width: 280 // 小程序码的宽度
				  },
				  success: res => {
					  console.log(res,'11111')
				    // 接口调用成功，获取生成的小程序码
				    const qrCodeUrl = res.result.qrCodeUrl;
				    // 将小程序码展示给用户
				    // ...
				  },
				  fail: err => {
				    // 接口调用失败
				    console.error(err);
				  }
				});
			},
			// 数据初始化
			async getPointsByZhuanFa() {
				let datas = {
					app_id: this.$https.weixinAppId,
					project_id: getApp().globalData.projectId,
					open_id: uni.getStorageSync("openid"),
				};
				index.getPointsByZhuanFa(datas).then(result => {
					if (result.code == 1) {
						uni.removeStorage({
							key: 'fenx',
							success: function (res) {
							}
						});
					}
				})
			},
			// 数据初始化
			async initData() {
				
			},
			
			onShareAppMessage: function (res) {
			  var share_title = '分类列表';
			  var share_id = 1212;
			  var id = 9999;
			  var share_path = `page_points/page_points/points_mall?id=${id}&share_id=${share_id}`;
			
			  return {
			    title: share_title,
			    path: share_path,
			    success: function (res) {
			      // 转发成功
			    },
			    fail: function (res) {
			      // 转发失败
			    }
			  }
			}
		
		},
		globalData: {
			projectId: '',
			
		},
		
	}

</script>

<style lang="scss">
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	@import "@/uni_modules/uview-ui/index.scss";
	
</style>
